/*PGBD - T2_3 
Otávio Cassel
Raphael Miollo
Leonardo Steffenello*/

package Model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class Tabela extends AbstractTableModel {
    
    private static int numTransacoes = 1;
    private ArrayList<String> tlist;
    private String[] columnName = {"T"+(numTransacoes++)};

    public Tabela() {
        this.tlist = new ArrayList<>();
    }

    //Adicionar
    public void add(String t) {
        this.tlist.add(t);
        fireTableRowsInserted(tlist.size() - 1, tlist.size() - 1);
    }
    
    public void limpaArray(){
        this.tlist.clear();
        fireTableRowsInserted(tlist.size() - 1, tlist.size() - 1);
    }

    @Override
    public int getRowCount() {
        return tlist.size();
    }

    @Override
    public int getColumnCount() {
        return columnName.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return columnName[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return tlist.get(rowIndex);
        }
        return null;
    }
}
